//无重复字符的最长子串

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int n = s.size();
        int ret = 0;
        unordered_set<char> set;
        for(int left = 0,right = 0;right < n; right++)
        {
            auto it = set.find(s[right]);
            if(it != set.end())
            {
                while(set.count(s[right]) != 0)
                {
                    set.erase(s[left++]);
                }
            }
            set.insert(s[right]);
            ret = max(right - left + 1, ret);
        }
        return ret;
    }
};